<template>
  <div class="home">
    <header>
      <div class="title">心里健康指数智能监控系统</div>
      <ul>
        <li style="cursor: pointer;">全屏</li>
        <li style="cursor: pointer;">testadmin(机构管理员)</li>
      </ul>
    </header>
    <div class="nav" ref="nav">
      <div class="classifl" @mouseover="xian(0)" @mouseout="ying()">
        <div class="top" @click="flag=!flag">
          机构管理
          <span class="shan" :flag="flag"></span>
        </div>
        <ul :flag="flag">
          <li @click="show = 1" :show="show == 1">基本信息</li>
          <li @click="qh(2,'memberlist')" :show="show == 2">成员列表</li>
          <li @click="show =3" :show="show == 3">用户管理</li>
        </ul>
      </div>
      <div class="classifl" @mouseover="xian(1)" @mouseout="ying()">
        <div class="top" @click="flag1=!flag1">
          订单管理
          <span class="shan" :flag="flag1"></span>
        </div>
        <ul :flag="flag1">
          <li @click="qh(4,'order-list')" :show="show == 4">订单列表</li>
          <li @click="show =5" :show="show == 5">消费记录</li>
        </ul>
      </div>
      <div class="classifl" @mouseover="xian(2)" @mouseout="ying()">
        <div class="top" @click="flag2=!flag2">
          问卷管理
          <span class="shan" :flag="flag2"></span>
        </div>
        <ul :flag="flag2">
          <li @click="show =6" :show="show == 6">VA问卷管理</li>
          <li @click="show =7" :show="show == 7">PH问卷管理</li>
          <li @click="show =8" :show="show == 8">NCP问卷管理</li>
        </ul>
      </div>
      <div class="gg" ref="gg"></div>
    </div>
    <section>
      <router-view></router-view>
    </section>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      show: 1,
      flag: false,
      flag1: false,
      flag2: false
    };
  },
  methods: {
    xian(i) {
      let gg = this.$refs.gg;
      let num = this.$refs.nav.children[i].offsetTop;
      gg.style.transform = "scaleY(1)";
      gg.style.top = num + "px";
    },
    ying() {
      let gg = this.$refs.gg;
      gg.style.transform = "scaleY(0)";
    },
    qh(i,r){
      this.show =i
      this.$router.push(r)
    }
  },
};
</script>
<style lang="scss" scoped>
.home {
  height: 100%;
  overflow: hidden;
}
header{
  height: 60px;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: #23262e;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .title{
    color: #059688;
  }
  ul{
    padding: 0 20px;
    display: flex;
    align-items: center;
    color: #ccc;
    font-size: 14px;
    li{
      padding: 0 20px;
    }
  }
}
section{
  background: #f5f5f5;
  margin-left: 200px;
  padding-top: 60px;
  height: 100%;
  overflow: hidden;
  overflow-y:auto; 
  box-sizing: border-box;
}
.nav {
  width: 200px;
  height: 100%;
  background: #393d49;
  position: fixed;
  top: 60px;
  left: 0;
  .gg {
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 45px;
    background: #009688;
    transition: top 0.2s, transform 0.2s;
    z-index: 100;
  }
  .classifl {
    .top,
    ul li {
      height: 45px;
      line-height: 45px;
      padding-left: 20px;
      box-sizing: border-box;
      font-size: 14px;
    }
    .top {
      background: #393d49;
      color: #fff;
      position: relative;
      &:hover {
        background: #4e5465;
      }
      .shan {
        width: 0;
        height: 0;
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        border-top: 6px solid #ccc;
        border-right: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-left: 6px solid transparent;
        margin-top: 5px;
        transition: border-color 0.3s, margin-top 0.3s;
        &[flag] {
          border-top: 6px solid transparent;
          border-bottom: 6px solid #fff;
          margin-top: -5px;
        }
      }
    }
    ul {
      &[flag] {
        display: none;
      }
      li {
        background: #282b33;
        color: #bfc0c2;
        transition: background 0.3s;
        &[show] {
          background: #009688;
          color: #fff;
        }
        
      }
    }
  }
}
</style>